gusucode.com > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM源码程序 > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM\stprtool\svm\m2osor.m

    function [model]=m2osor( data, labels, ker, arg, C, eps)
% M2OSOR One-Against-All multiclass SVM classifier using M-2-O 
%  transform and SOR.
% [model]=m2osor( data, labels, ker, arg, C, eps) 
%
% It transforms multi-class SVM problem to a modified single-class
% SVM problem and uses Succesive Overrelaxation method to solve it. 
%
% Use 'oaaclass' for classification.
%
% Inputs:
%  data [dim x N] training patterns
%  labels [1 x N] labels of training patterns
%  ker [string] kernel, see 'help kernel'.
%  arg [...] argument of given kernel, see 'help kernel'.
%  C [real] trade-off between margin and training error.
%  eps  [real] stopping condition.
% 
% Output:
%  model [struct] contains found multi-class SVM classifier.
%
% See also
%  OAACLASS

% Modifications:
% 9-july-2002, VF

if nargin < 5,
  error('Not enough input aruments.');
end

if nargin < 6,
  eps= 0.001;
end  

if nargin < 7,
  tol=0.001;
end

%---------------------------------

[dim,num_data]=size(data);

num_classes=max(labels);

%---------------------------------

[Alpha,bias,kercnt] = m2o_sor(data,labels,ker,arg,C,eps);

model.name = 'Multi-To-One class, SVM classifier';
model.num_classes = num_classes;
model.num_rules = num_classes;
model.rule = cell(model.num_rules);

for i=1:num_classes,
  model.rule{i}.Alpha = Alpha(i,:);
  model.rule{i}.bias = bias(i);
end

model.SVM.C = C;
model.SVM.kernel = ker;
model.SVM.arg = arg;

model.trn_data = data;
model.trn_labels = labels;
model.kercnt = kercnt;
%model.trnerr = ;

model.nsv = length(find(sum(Alpha)));  

return;

% EOF